<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset=utf8>
</head>
<body>
   <form name="addform" action="1.php" method="post" onsubmit="return checkForm()">
        <table>
            <tr>
                <td>邮箱: </td>
                <td><input type="text" name="email"></td>
            </tr>
            <tr>
                <td>用户名: </td>
                <td><input type="text" name="user"></td>
            </tr>
            <tr>
                <td>密码: </td>
                <td><input type="password" name="pass"></td>
            </tr>
            <tr>
                <td>确认密码: </td>
                <td><input type="password" name="repass"></td>
            </tr>
            <tr>
                <td></td>
                <td><button type="submit">注册</button></td>
            </tr>
        </table>
    </form>
    <script>
     function checkForm(){
      //获取邮箱
      var email = document.addform.email.value;
      //console.log(email);
      if(email.match(/^[\w\.-]+@\w+(\.\w+){1,3}$/)===null)
      {
        alert('邮箱格式有误');
        return false;
      }

      var user = document.addform.user.value;
      if(! /\w{6,18}/.test(user))
      {
        alert("用户名格式不对");
        return false;
      }

      var pass = document.addform.pass.value;
      if(pass.length<6||pass.length>18)
      {
        alert('密码长度不合法');
        return false;
      }

      var repass = document.addform.repass.value;
      if(pass!==repasa)
      {
        alert('密码不一样');
        return false;
      }



      return true;
    }
    </script>
    
</body>
</html>